<script setup>



import {useRouter} from "vue-router";
const router=useRouter();
import {ref} from "vue";
import axios from "axios";
import {showToast} from "vant";
import {get} from "../../util/request.js";

const loading = ref(false);
const finished = ref(false);

const activeTabs = ref('全部订单');
const collection =ref({})
const active = ref('0');
// const onLoad = ()=>{
//   axios({
//     method:'get',
//     url:'http://localhost:8081/api/order/findAllOrders'
//   }).then((data) => {
//     console.log(JSON.stringify(data))
//     console.log("获取处理器的数据：" + JSON.stringify(data.data))
//     var r = data.data;
//
//     // 加载状态结束
//     loading.value = false;
//     finished.value = true
//
//     if (r.code == 0) {
//       showToast("查询成功");
//       orders1.value = r.data;// 初始化界面
//
//     } else {
//       showToast("查询失败");
//     }
//
//
//   })
// }
const changeTab=()=>{
  console.log(active.value)
  get(`order/findAllOrderByType?status=${active.value}`).then((response) => {
    console.log(JSON.stringify(response))
    console.log("获取处理器的数据：" + JSON.stringify(response))
    const {code,msg,data}=response
    if (code === 0) {
      console.log("查询成功数据为：" + JSON.stringify(data))
      showToast("查询成功");
      collection.value = data;// 初始化界面
    }else {
      showToast("查询失败");
    }
  })
}
const onClickLeft1 = () => {
  router.push('/my');
}
const onClickLeft2 = () => {
  router.push('/orderPay');
}
const syMessage = [
  // { id: 1, content: '关于建筑考试内容有什么建议吗？' },
  // { id: 2, content: '如何写一封好的建筑信？' },
  // 其他私信内容
];
</script>

<template>
<h1>我叫喻文波</h1>
  <van-nav-bar
      title="我的消息"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft1"
  />



    <van-tabs v-model:active="active" @change="changeTab">
      <van-tab title="所有订单" neme="0">
        <van-list
            v-model="loading"
            :finished="finished"
            finished-text="没有更多了"

        >
          <van-cell v-for="(collection, index) in collection"
                    :key="index" :title="collection.orderId"
                    :label="collection.userId" is-link
                    :value="collection.status"

          >
          </van-cell>
        </van-list>
      </van-tab>
      <van-tab title="未付款" name="1">
        <van-cell-group>
          <van-list>

            <van-cell v-for="(collection, index) in collection"
                      :key="index" :title="collection.orderId"
                      :label="collection.userId" is-link
                      :value="collection.status"
                      @click="onClickLeft2"
            >
            </van-cell>
          </van-list>
        </van-cell-group>
      </van-tab>
      <van-tab title="已付款" name="2">
        <van-cell-group>
          <van-list>
            <van-cell v-for="(collection, index) in collection"
                      :key="index" :title="collection.orderId"
                      :label="collection.userId" is-link
                      :value="collection.status"
            >
            </van-cell>
          </van-list>
        </van-cell-group>
      </van-tab>

    </van-tabs>



</template>

<style scoped>

</style>